/**
 * 
 */
package com.sf.osms.dep.groovy

import com.sf.osms.dep.domain.Router
import java.util.List
import java.util.Map
import java.util.Calendar
import java.util.Date
import com.sf.osms.dep.processor.util.DateUtil
/**
 * @author sfhq1405
 *
 */
public class TimeZoneTransfer implements GroovyInterface{

	
	
	/* (non-Javadoc)
	 * @see com.sf.osms.dep.groovy.GroovyInterface#hanleCorrectRoutersList(java.util.List)
	 */
	public void hanleCorrectRoutersList(List list){
		// TODO Auto-generated method stub
	}
	
	/* (non-Javadoc)
	 * @see com.sf.osms.dep.groovy.GroovyInterface#handleSimgleOrginalRouter(java.util.Map)
	 */
	public void handleSimgleOrginalRouter(Map map){
		// TODO Auto-generated method stub
	}
	
	/* (non-Javadoc)
	 * @see com.sf.osms.dep.groovy.GroovyInterface#handleSimgleRouter(com.sf.osms.dep.domain.Router)
	 */
	public void handleSimgleRouter(Router router){
		if(null != router.barDate && null != router.barTime && null != router.eventCode){
			if(44 == router.eventCode){
				tranferTimeZone(router,3);
			}else{
				tranferTimeZone(router,6);
			}
		}
	}
	
	private void tranferTimeZone(Router router,int hours){
		Calendar dateTransfer = Calendar.getInstance();
		dateTransfer.setTime(DateUtil.formatDate(DateUtil.dateFomat(router.getBarDate(), "yyyy-MM-dd")+
								 DateUtil.dateFomat(router.getBarTime(), "HH:mm:ss")));
		dateTransfer.add(Calendar.HOUR_OF_DAY,hours);
		router.setBarDate(dateTransfer.getTime());
		router.setBarTime(dateTransfer.getTime());
	}
	
}
